package com.zjitc.service.impl;

import com.zjitc.dao.AdminDao;
import com.zjitc.model.*;
import com.zjitc.service.AdminService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/5/28 16:51
 * @description:
 */
@Service
public class AdminServiceImpl implements AdminService{
@Autowired AdminDao adminDao;

  @Override
  public Adminuser doLogin(String username, String password) {
    int count = adminDao.checkUsername(username);
    if (count != 1) {
      return null;
    }
    Adminuser adminuser = adminDao.findByUserNameAndPassword(username, password);
    if (adminuser == null) {
      return null;
    }

    return adminuser;
  }

  @Override
  public List<User> findAllUser() {
    return adminDao.findAllUser();

  }

  @Override
  public void userDelete(Integer uid) {
    adminDao.userDelete(uid);
  }

  @Override
  public List<Category> findAllCategory() {
    return adminDao.findAllCategory();
  }

  @Override
  public void add(Category category) {
    adminDao.add(category);
  }

  @Override
  public void delete(Integer cid) {
    adminDao.delete(cid);
  }

  @Override
  public void update(Category category) {
    adminDao.update(category);
  }

  @Override
  public Category findByCid(Integer cid) {
    return adminDao.findByCid(cid);
  }

  @Override
  public List<CategorySecond> findAllCS() {
    return adminDao.findAllCS();
  }

  @Override
  public CategorySecond findByCsid(Integer csid) {
    return adminDao.findByCsid(csid);
  }

  @Override
  public void csAdd(CategorySecond categorySecond) {
    adminDao.csAdd(categorySecond);
  }

  @Override
  public void csDelete(Integer csid) {
    adminDao.csDelete(csid);
  }

  @Override
  public void csUpdate(CategorySecond categorySecond) {
    adminDao.csUpdate(categorySecond);
  }

  @Override
  public void pAdd(Product product) {
    adminDao.pAdd(product);
  }

  @Override
  public void pDelete(Integer pid) {
    adminDao.pDelete(pid);
  }

  @Override
  public void pUpdate(Product product) {
    adminDao.pUpdate(product);
  }
}
